<?php

/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2023-04-13 21:59:48
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2023-06-06 15:14:41
 */

namespace Common;

use Hyperf\Constants\AbstractConstants;
use Hyperf\Constants\Exception\ConstantsException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class BaseEnum extends AbstractConstants
{
    /**
     */
    public static function getNames(): array
    {
        $enumClass = static::class;
        $reflectionClass = new \ReflectionClass($enumClass);
        $constants = $reflectionClass->getConstants();

        return array_keys($constants);
    }

    /**
     */
    public static function getVals(): array|string
    {
        $enumClass = static::class;
        $reflectionClass = new \ReflectionClass($enumClass);
        $constants = $reflectionClass->getConstants();
        return array_values($constants);
    }

    static function getVal($key)
    {
        $enumClass = static::class;
        $reflectionClass = new \ReflectionClass($enumClass);
        $constants = $reflectionClass->getConstants();
        return $constants[$key];
    }


}
